<?php

namespace App\Admin\Extension\Expand;

use App\Models\TongGoodsGroupValue;
use Dcat\Admin\Support\LazyRenderable;
use Dcat\Admin\Widgets\Table;
class GoodsGroupValue extends LazyRenderable
{

    public function render()
    {
        // TODO: Implement render() method.
        $attribute_id = $this->key;
        $attributes = TongGoodsGroupValue::where('goods_group_id', $attribute_id)->get(['id', 'name']);
        $data = $attributes->map(function (TongGoodsGroupValue $attributeValueModel, $key) {
            return [
                'id' => $key + 1,
                'name' => $attributeValueModel->name,
            ];
        })->toArray();
        $titles = [
            '序号',
            '值名称',
        ];
        return Table::make($titles, $data);
    }
}
